package com.xm.shop.app.api.controller;

import com.xm.shop.pojo.entity.Item;
import com.xm.shop.pojo.qo.ItemAddQO;
import com.xm.shop.pojo.vo.RespResult;
import com.xm.shop.service.ItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ludi
 * @date:2020/9/1 10:30
 * @description:购物车转订单控制层
 */
@Controller
@RestController
@RequestMapping("/item")
@Api(tags = "购物车转订单业务接口")
public class ItemController extends BaseController{
    @Autowired
    private ItemService itemService;

    @PostMapping("/addItem")
    @ApiOperation("添加订单详情")
    public RespResult addItem(@RequestBody ItemAddQO itemAddQO){
        Integer value = itemService.addItem(itemAddQO);
        return returnRespWithSuccess(value);
    }

    @GetMapping("/selectItemByOrderId")
    @ApiOperation("查看订单详情")
    public RespResult selectItemByOrderId(Integer orderId){
        List<Item> list = itemService.selectByOrderId(orderId);
        return returnRespWithSuccess(list);
    }
}
